package com.nikmesoft.android.referendumfriend.activities;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;

import com.nikmesoft.android.referendumfriend.R;

public class Profile_info extends BaseActivity {
	EditText ed1, ed2, ed3;
	RadioButton rdmale, rdfemale;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.information_layout);

		ed1 = (EditText) findViewById(R.id.ed1);
		ed2 = (EditText) findViewById(R.id.ed2);
		ed3 = (EditText) findViewById(R.id.ed3);
		rdfemale = (RadioButton) findViewById(R.id.rdfemale);
		rdmale = (RadioButton) findViewById(R.id.rdMale);
	}

	public void callBack(View view) {
		finish();
	}

	public void callSave(View view) {
		if (ed1.getText().toString().equals("")
				|| ed2.getText().toString().equals("")
				|| ed3.getText().toString().equals("")
		 || (rdfemale.isChecked() == false && rdmale.isChecked() == false)
		) {
			AlertDialog.Builder builder = new AlertDialog.Builder(
					Profile_info.this);
			builder.setTitle("Info missing");
			builder.setMessage("Please enter all information");
			builder.setPositiveButton("Continue",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {
						}
					});
			builder.show();
		} else {

			Intent intentSave = new Intent();
			intentSave.putExtra("fullname", ed1.getText().toString());
			intentSave.putExtra("username", ed2.getText().toString());
			intentSave.putExtra("birth", ed3.getText().toString());
			if (rdfemale.isChecked() == true)
				intentSave.putExtra("gender", "Female");
			intentSave.putExtra("gender", "Male");
			setResult(RESULT_OK, intentSave);
			finish();
		}
	}
}
